import request from "@/utils/request";

const FAULT_REPORT_BASE_URL = "/api";

/**
 * 故障报告 API 模块
 */
export const FaultReportAPI = {
  /**
   * 获取新故障报告详情（适配 /api/fault/1）
   * @param id 故障报告ID
   */
  getFaultReportByCpuId(cpuId: number | string) {
    return request<any, FaultReportItem[]>({
      url: `${FAULT_REPORT_BASE_URL}/fault/${cpuId}`,
      method: "get",
    });
  },
};

/**
 * 新故障报告 SOE 条目
 */
export interface SoeItem {
  relative_time: number;
  name: string;
  values?: {
    name: string;
    value: string;
    unit: string;
  }[];
}

/**
 * 新故障报告结构
 */
export interface FaultReportItem {
  fault_file_name: string;
  index: number;
  datetime: string;
  type: string;
  phrase?: string;
  distance?: string;
  action?: string;
  duration?: string;
  soe: SoeItem[];
}
